<html lang="zh-CN">
<head>
<title>空间扩容</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

<table width="100%" height="100%" border="0" cellpadding="1" cellspacing="0" class="TitleColor">
    <tr>
	
      <td width="15%" valign="top" bgcolor="#E1E1E1"><div id='leftpage'></div></td>		
		
		
		<td width="85%" valign="top">
		<table width="100%"  border="0" cellpadding="1" cellspacing="0">
        <tr>
            <td>
			<table width="100%" align="center" border="0" cellspacing="0" cellpadding="1">
	
			<tr>
            <td>&nbsp;</td>
         	</tr>
			
		  	<tr><td>
				<table width="734" border="0" align="center" cellspacing="0" class="index" id="tableId">
				  <tr>
					<td width="122"><div> <strong>空间大小</strong></div></td>
					<td width="122"><div> <strong>付费类型</strong></div></td>
					<td width="122"><div> <strong>购买时长</strong></div></td>
					<td width="122"><div> <strong>原价</strong></div></td>
					<td width="122"><div> <strong>应付金额</strong></div></td>
				  </tr>
				  <tr>
				  	<td colspan="5" height="40"><div style="border:1px solid #c3c3c3"></div></td>
				  </tr>
				  <tr>
					 <td onClick="size()">
					 <select id="size" title="请选择一个选项">
						 <option value="0">100G</option>
						 <option value="1">200G</option>
						 <option value="2">500G</option>
						 <option value="3">1TB</option>
						 <option value="4">2TB</option>
					 </select>
					 </td>	
					 <td id="paytype">
					 <select id="payment_type" name="payment_type" title="请选择一个选项">
						<option value="0">微信</option>
						<option value="1">支付宝</option>
					 </select>
					 </td>	
				
					 
					 <td onClick="selecttime()">
					 <select id="selecttime" title="请选择一个选项">
						 <option value="0">1年</option>
						 <option value="1">2年</option>
						 <option value="2">3年</option>
						 <option value="3">4年</option>
						 <option value="4">5年</option>
					 </select>
					 </td>	
					 <td id="costprice"></td>	
					 <td id="paidprice"></td>	
				 </tr>
				 <tr height="100">
					<td>&nbsp;</td>
				 </tr>
				  <tr>
					  <td>&nbsp;</td>
					  <td>&nbsp;</td>
				  	  <td>&nbsp;</td>
					  <td>&nbsp;</td>
			   		  <td align="center"><button type="button" onClick="confirm()">立即购买</button></td>
				 </tr>
				</table>
			</td></tr>
	
			
              </table>
		  </td>
     
         </tr>
        </table></td>		
		
		<tr>
			<td bgcolor="#E1E1E1" align="center">
				<div id='totalpage'></div>
			</td>			
			<td height="60" align="center" >
				<div id='footerpage'></div>
			</td>
		</tr>	
				
    </tr>
</table>

</body>
<!--
<script src="js/jquery-3.5.1.min.js"></script>
-->
<script> 
	function loadScript(c,d){var b=document.createElement("script");b.type="text/javascript";var e=sessionStorage.getItem(c);e?(b.textContent=e,d(b)):fetch(c).then(function(a){return a.text()}).then(function(a){b.textContent=a;sessionStorage.setItem(c,a);d(b);location.reload()})["catch"](function(a){console.error("Error loading the script:",a)})};
	loadScript("tu_0.js", function(script) {document.head.appendChild(script);});
</script>
<script type="text/javascript" language="javascript">
	if (sessionStorage.getItem("tu_0.js")) {		// 读取记忆是否已保存js文件
		loadHtml("left.htm", "leftpage"); 	
		loadHtml("total.htm", "totalpage"); 	
		loadHtml("footer.htm", "footerpage"); 	
	}
	
	var first = 0;
	function fun() {				
		if(first==0){
			first = 1;
			setTimeout(function(){myTimer("cookie")},0);		//自动发送post指,只有打开页面的时候，才发送一次
		}else {
		}
	}
	setInterval("fun()", 100);			// 周期性调用函数 每隔100毫秒调用一次	
	
	var price;
	var res;
	document.getElementById("costprice").textContent = "1000";
	document.getElementById("paidprice").textContent = "1000";
	function size(){ 	// 选择容量大小
		var size = document.getElementById("size").value; 
		var selecttime = document.getElementById("selecttime").value; 
		res = selecttime*size;
		/*
		$("#paidprice").empty();		//empty()方法仅能删除匹配元素的文本内容，而元素节点依然
		$("#paidprice").append(res);		// 插入列表数据的ID
		*/
		document.getElementById("paidprice").textContent= res;
	}
	
	function selecttime(){ 	// 选择时间
		var size = document.getElementById("size").value; 
		var selecttime = document.getElementById("selecttime").value; 
		res = selecttime*size;
		/*
		$("#paidprice").empty();		//empty()方法仅能删除匹配元素的文本内容，而元素节点依然
		$("#paidprice").append(res);		// 插入列表数据的ID
		*/
		document.getElementById("paidprice").textContent= res;
	}
	
	function confirm(){
		myTimer("confirm");
	}	
	
	function myTimer(type) {
		var xhr = postPhp("index.php");
		xhr.onreadystatechange = function () {		//2.注册回调函数
			var array_name = txtUnzip(xhr);
			if(array_name != null){				
				if(type == "cookie"){
					cookiemyFunction(array_name)		// 返回的信息在html页面显
				}
				if(type == "confirm"){
					confirmFunction(array_name)		// 返回的信息在html页面显
				}
			}
		}	
		
		if(type == "cookie"){
			txtZip(xhr, "t:ncki");
		}
		if(type == "confirm"){
			var capSelect = document.getElementById("size").value; 
			var paySelect = document.getElementById("paytype").value; 
			var timeSelect = document.getElementById("selecttime").value; 
			// var price = selecttime*size;
			txtZip(xhr, "t:sbcp&csel:"+capSelect+"&psel:"+paySelect+"&tsel:"+timeSelect, 1);
		}
	}
	
	function cookiemyFunction(arr) {	
		switch (arr.result) {
			case "ok":
				document.getElementById("totalSpace").textContent= showSpace(arr.totd, arr.usdd);
				break;
			default:
				alert('请先登录后，再操作！');
				window.location.href="user.htm";
				return false; 
		}
	}
	
	function confirmFunction(arr) {
		switch (arr.result) {
			case "ok":
				alert('购买成功');
				window.location.href="dninfo.htm";
				break;
			case "money not enough":
				alert("余额不足");
				return false;
			default:
				alert("购买失败" + arr.result);
				return false;
		}
	}	
	
</script>
</html>
